﻿Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

<WebService(Namespace:="http://www.resamu.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class user
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function Identification(ByVal idresamu As String, ByVal pwd As String, ByVal idpers As String) As String
        Dim dbUser As New LogDataSetTableAdapters.user_detailTableAdapter
        Dim data As New LogDataSet.user_detailDataTable
        Dim survey As New surveillance.logsurvey
        survey.Timeout = 60000
        survey.Url = Application("LogAdresse")
        Dim InfoPers As New ResaFdxml.ResaFdxml
        InfoPers.Url = Application("GestionFDXML")
        InfoPers.Timeout = 60000
        Dim resultat As String
        Dim analyse As String
        Try
            data = dbUser.GetDataById(idresamu)
            If data(0).user_pwd = pwd Then
                resultat = "IDOK/" + data(0).user_droit + "/" + data(0).user_type + "/" + data(0).user_nom + "/" + _
                data(0).user_prenom + "/" + data(0).user_SAMUref + "/" + data(0).user_videoid
                Try
                    analyse = InfoPers.GetPersInfo("Res@Core16", idresamu, idpers)
                    resultat = resultat + "/" + analyse
                Catch ex As Exception
                    resultat = resultat + "/" + "NOTEAM"
                End Try
            Else
                resultat = "INTRUSION"
            End If
        Catch ex As Exception
            resultat = "ERROR/" + ex.Message
        End Try
        Try
            survey.NewLog(idresamu, "system", "system", "Identification", resultat)
        Catch ex As Exception
        End Try
        Return resultat
    End Function
    <WebMethod()> _
    Public Function GetUserFullInfo(ByVal idresamu As String, ByVal pwd As String) As System.Xml.XmlDocument
        Dim dbUser As New LogDataSetTableAdapters.user_detailTableAdapter
        Dim data As New LogDataSet.user_detailDataTable
        Dim survey As New surveillance.logsurvey
        survey.Timeout = -1
        survey.Url = Application("LogAdresse")
        Dim resultat As String
        Dim info As New System.Xml.XmlDocument
        Try
            data = dbUser.GetDataById(idresamu)
            If data(0).user_pwd = pwd Then
                info.LoadXml("<USERINFO></USERINFO>")
                Dim elementa As System.Xml.XmlElement

                elementa = info.CreateElement("pwd")
                Try
                    elementa.InnerText = data(0).user_pwd
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

                elementa = info.CreateElement("droit")
                Try
                    elementa.InnerText = data(0).user_droit
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

                elementa = info.CreateElement("type")
                Try
                    elementa.InnerText = data(0).user_type
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

                elementa = info.CreateElement("samuref")
                Try
                    elementa.InnerText = data(0).user_SAMUref
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

                elementa = info.CreateElement("nom")
                Try
                    elementa.InnerText = data(0).user_nom
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

                elementa = info.CreateElement("prenom")
                Try
                    elementa.InnerText = data(0).user_prenom
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

                elementa = info.CreateElement("adresse")
                Try
                    elementa.InnerText = data(0).user_adresse
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

                elementa = info.CreateElement("cp")
                Try
                    elementa.InnerText = data(0).user_cp
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

                elementa = info.CreateElement("commune")
                Try
                    elementa.InnerText = data(0).user_commune
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

                elementa = info.CreateElement("utmx")
                Try
                    elementa.InnerText = data(0).user_utmx
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

                elementa = info.CreateElement("utmy")
                Try
                    elementa.InnerText = data(0).user_utmy
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

                elementa = info.CreateElement("tel")
                Try
                    elementa.InnerText = data(0).user_tel
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

                elementa = info.CreateElement("mail")
                Try
                    elementa.InnerText = data(0).user_mail
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

                elementa = info.CreateElement("videoid")
                Try
                    elementa.InnerText = data(0).user_videoid
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

                elementa = info.CreateElement("rem")
                Try
                    elementa.InnerText = data(0).user_rem
                Catch ex As Exception
                    elementa.InnerText = ""
                End Try
                info.DocumentElement.AppendChild(elementa)

            Else
                info.LoadXml("<ERROR>INTRUSION</ERROR>")
                resultat = "ERROR/INTRUSION"
            End If
        Catch ex As Exception
            info.LoadXml("<ERROR>" + ex.Message + "</ERROR>")
            resultat = "ERROR/" + ex.Message
        End Try
        Try
            survey.NewLog(idresamu, "system", "system", "Identification", resultat)
        Catch ex As Exception
        End Try
        Return info
    End Function

End Class
